-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: removing unnecessary optionals and increasing branch cov - 1 #2503
Conversation
); | ||
expect(trackingService.showToastMessage).toHaveBeenCalledOnceWith({ | ||
ToastContent: 'Successfully removed the card details from the expense.', | ||
}); | ||
})); | ||
|
||
it('should go back to my expenses page if etxn is undefined', fakeAsync(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes here
done(); | ||
}); | ||
|
||
it('should get all action sheet options and call titleCasePipe transform method if project_id is defined', (done) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change here
@@ -586,15 +586,15 @@ export class AddEditExpensePage implements OnInit { | |||
combineLatest(this.fg.controls.currencyObj.valueChanges, this.fg.controls.tax_group.valueChanges).subscribe(() => { | |||
if ( | |||
this.fg.controls.tax_group.value && | |||
isNumber(taxGroupControl.value?.percentage) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have checked for this.fg.controls.tax_group.value
, then no need to check for nullity again
this.fg.controls.currencyObj.value | ||
) { | ||
const amount = | ||
currencyObjControl.value?.amount - currencyObjControl.value?.amount / (taxGroupControl.value?.percentage + 1); | ||
currencyObjControl.value.amount - currencyObjControl.value.amount / (taxGroupControl.value.percentage + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have checked for this.fg.controls.currencyObj.value
, then no need to check again
|
||
const formattedAmount = this.currencyService.getAmountWithCurrencyFraction( | ||
amount, | ||
currencyObjControl.value?.currency | ||
currencyObjControl.value.currency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
|
||
let actionSheetOptions; | ||
|
||
component.getActionSheetOptions().subscribe((res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's name the variables with proper names based on context. res can be what is the response we get eg: like bankAccountResponse, transactionsResponse etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here it can be actionSheetOptionsResponse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, changing...
let actionSheetOptions; | ||
|
||
component.getActionSheetOptions().subscribe((res) => { | ||
actionSheetOptions = res; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we assigning res to actionSheetOptions? & I don't see it's usage
component.recentlyUsedValues$ = of(recentlyUsedRes); | ||
fixture.detectChanges(); | ||
|
||
component.getNewExpenseObservable().subscribe((res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
…2504) * test: removing unnecessary optionals and increasing branch cov - 2 * pr comments * test: removing unnecessary optionals and increasing branch cov - 3 (#2505) * test: removing unnecessary optionals and increasing branch cov - 3 * minor * minor * test: removing unnecessary optionals and increasing branch cov - 4 (#2506) * test: removing unnecessary optionals and increasing branch cov - 4 * minor
… into rem-branches-test
|
Description
🤖 Generated by Copilot at 881e2a6
Added and updated test cases for add-edit-expense page and fixed compatibility issues with older devices. The test cases cover new scenarios for transaction fields, corporate card expenses, and autofill settings. The compatibility issues were caused by the optional chaining operator in
taxGroupControl.value
andcurrencyObjControl.value
expressions inadd-edit-expense.page.ts
.🤖 Generated by Copilot at 881e2a6
Walkthrough
🤖 Generated by Copilot at 881e2a6
taxGroupControl.value
andcurrencyObjControl.value
expressions inAddEditExpensePage
class to avoid runtime errors on older devices (link)expense-field-obj.data
to import statement inadd-edit-expense-1.spec.ts
for testing transaction fields (link)removeCorporateCardExpense
method whenetxn$
observable is undefined inadd-edit-expense-1.spec.ts
and expect it to callgoBack
method (link)getActionSheetOptions
method whenproject_id
is defined inadd-edit-expense-1.spec.ts
and expect it to return six action sheet options and verify their handlers (link)getNewExpenseObservable
method when autofill settings are disabled and recently used currency is undefined inadd-edit-expense-3.spec.ts
and expect it to return a new expense observable with home currency and source (link)TestBed.inject
,corporateCreditCardExpenseService
,transactionService
,popoverController
,trackingService
,orgSettingsService
, andlaunchDarklyService
statements inadd-edit-expense-1.spec.ts
to remove trailing commas and align closing parentheses for readability and consistency (link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link)Clickup
app.clickup.com
Code Coverage
Please add code coverage here
UI Preview
Please add screenshots for UI changes